import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'dart:developer' as developer;

import 'index.dart';

class SplashPage extends GetView<SplashController> {
  const SplashPage({super.key});

  // 主视图
  Widget _buildView() {
    return Stack(
      fit: StackFit.expand,
      children: [
        // 红色背景 E33641
        Container(
          color: const Color(0xFFE33641),
        ),
        
        // 中央Logo - 向上移动25%
        Positioned(
          top: MediaQuery.of(Get.context!).size.height * 0.15, // 从顶部15%位置开始
          left: 0,
          right: 0,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              // 顶部域名框
              Container(
                padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
                decoration: BoxDecoration(
                  border: Border.all(color: Colors.white, width: 2),
                  borderRadius: BorderRadius.circular(30),
                ),
                child: const Text(
                  '"playtruly.cn"',
                  style: TextStyle(
                    fontSize: 16,
                    color: Colors.white,
                    fontWeight: FontWeight.w400,
                  ),
                ),
              ),
              const SizedBox(height: 40),
              // 主标题
              const Text(
                '玩真的',
                style: TextStyle(
                  fontSize: 64,
                  fontWeight: FontWeight.w900,
                  color: Colors.white,
                  letterSpacing: 16,
                  shadows: [
                    Shadow(
                      blurRadius: 8.0,
                      color: Colors.black26,
                      offset: Offset(2.0, 2.0),
                    ),
                  ],
                ),
              ),
              const SizedBox(height: 30),
              // 底部标语
              const Text(
                '怎么开心怎么玩 ——— 一起终结孤单',
                style: TextStyle(
                  fontSize: 14,
                  color: Colors.white,
                  letterSpacing: 3,
                  shadows: [
                    Shadow(
                      blurRadius: 6.0,
                      color: Colors.black26,
                      offset: Offset(1.0, 1.0),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
        
        // 版本信息
        const Positioned(
          bottom: 30,
          left: 0,
          right: 0,
          child: Text(
            'v1.0.0',
            textAlign: TextAlign.center,
            style: TextStyle(
              color: Colors.white70,
              fontSize: 12,
            ),
          ),
        ),
        
        // 底部IPv6支持信息
        const Positioned(
          bottom: 10,
          left: 0,
          right: 0,
          child: Text(
            '本应用支持IPv6',
            textAlign: TextAlign.center,
            style: TextStyle(
              color: Colors.white54,
              fontSize: 10,
            ),
          ),
        ),
      ],
    );
  }


  @override
  Widget build(BuildContext context) {
    developer.log('SplashPage build');
    
    // 简化备用弹窗逻辑
    WidgetsBinding.instance.addPostFrameCallback((_) {
      developer.log('SplashPage postFrameCallback');
      // 不在这里显示弹窗，让控制器处理
    });

    return Scaffold(
      backgroundColor: const Color(0xFFE33641), // 设置与背景一致的颜色
      extendBodyBehindAppBar: true,
      // 添加透明AppBar确保状态栏样式一致
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
        toolbarHeight: 0, // 高度为0的透明AppBar
        automaticallyImplyLeading: false, // 不显示返回按钮
        systemOverlayStyle: const SystemUiOverlayStyle(
          statusBarColor: Colors.transparent,
          statusBarIconBrightness: Brightness.light,
          statusBarBrightness: Brightness.dark, // iOS
        ),
      ),
      extendBody: true,
      body: SafeArea(
        top: false, // 不为顶部留出安全区域，允许内容延伸到状态栏
        child: _buildView(),
      ),
    );
  }
}
